import { _decorator, Component, Node } from 'cc';
import { AudioManager } from '../../common/src/manager/AudioManager';
import { SETTING_TYPE } from '../../utils/Enums';
import { UIManager } from '../../framework/ui/uimanager/UIManager';
import { director } from 'cc';
import { assetManager } from 'cc';
import { sys } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('StartScene')
export class StartScene extends Component {
     // ------------------- 点击事件 ------------------- //
    public onClickSetButton() {
        AudioManager.playButton();
        UIManager.open("setting:res/prefab/SettingPanel", (res:Node)=>{
            res.getComponent("SettingPanel").setData({
                type: SETTING_TYPE.START
            })
        })
    }
    public onClickShareButton(){
        window.gameSdk.sdk.shareAppMessage({
            positionTag:"分享标记点位",
            callback: (err, res) => {
                if (!err) {
                    console.log("分享成功");
                }else{
                    console.log("分享失败");
                }
            }
        });
        
    }
    public onClickPlayButton(){
        AudioManager.playButton();
        assetManager.loadBundle('game', { version: sys.localStorage.getItem('__bundleVersionConfig__') }, (err, bundle) => {
            if (err) { return gg.error(err); }
            
            bundle.loadScene('game', (err, scene) => {
                if (err) { return gg.error(err); }
                director.runScene(scene);
            });
        });
    }
    public onClickRankButton(){
        AudioManager.playButton();
        UIManager.open("rank:res/prefab/RankPanel")
    }
}


